import Cookies from 'js-cookie';
import {tokenKey, userKey} from '@/const/keys';

/**
 * Token
 * @returns {*}
 */
export function getToken() {
  return window.sessionStorage.getItem(tokenKey);
  // return Cookies.get(tokenKey);
}

export function setToken(token) {
  return window.sessionStorage.setItem(tokenKey, token);
  // return Cookies.set(tokenKey, token);
}

export function removeToken() {
  return window.sessionStorage.setItem(tokenKey, '');
  // return Cookies.remove(tokenKey);
}

/**
 * userInfo
 * @returns {*}
 */
export function getUserInfo() {
  return JSON.parse(window.sessionStorage.getItem(userKey));
}

export function setUserInfo(user) {
  return window.sessionStorage.setItem(userKey, JSON.stringify(user));
}

export function removeUserInfo() {
  return window.sessionStorage.setItem(userKey, '');
}
